package com.ruoyi.web.controller.kycinfo;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kycinfo.domain.KycFinance;
import com.ruoyi.kycinfo.service.IKycFinanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * kyc金融信息Controller
 * 
 * @author kriby
 * @date 2023-11-24
 */
@RestController
@RequestMapping("/kycinfo/finance")
public class KycFinanceController extends BaseController
{
    @Autowired
    private IKycFinanceService kycFinanceService;

    /**
     * 查询kyc金融信息列表
     */
    @PreAuthorize("@ss.hasPermi('kycinfo:finance:list')")
    @GetMapping("/list")
    public TableDataInfo list(KycFinance kycFinance)
    {
        startPage();
        List<KycFinance> list = kycFinanceService.selectKycFinanceList(kycFinance);
        return getDataTable(list);
    }

    /**
     * 导出kyc金融信息列表
     */
    @PreAuthorize("@ss.hasPermi('kycinfo:finance:export')")
    @Log(title = "kyc金融信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KycFinance kycFinance)
    {
        List<KycFinance> list = kycFinanceService.selectKycFinanceList(kycFinance);
        ExcelUtil<KycFinance> util = new ExcelUtil<KycFinance>(KycFinance.class);
        util.exportExcel(response, list, "kyc金融信息数据");
    }

    /**
     * 获取kyc金融信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('kycinfo:finance:query')")
    @GetMapping(value = "/{financeId}")
    public AjaxResult getInfo(@PathVariable("financeId") Long financeId)
    {
        return success(kycFinanceService.selectKycFinanceByFinanceId(financeId));
    }

    /**
     * 新增kyc金融信息
     */
    @PreAuthorize("@ss.hasPermi('kycinfo:finance:add')")
    @Log(title = "kyc金融信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KycFinance kycFinance)
    {
        return toAjax(kycFinanceService.insertKycFinance(kycFinance));
    }

    /**
     * 修改kyc金融信息
     */
    @PreAuthorize("@ss.hasPermi('kycinfo:finance:edit')")
    @Log(title = "kyc金融信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KycFinance kycFinance)
    {
        return toAjax(kycFinanceService.updateKycFinance(kycFinance));
    }

    /**
     * 删除kyc金融信息
     */
    @PreAuthorize("@ss.hasPermi('kycinfo:finance:remove')")
    @Log(title = "kyc金融信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{financeIds}")
    public AjaxResult remove(@PathVariable Long[] financeIds)
    {
        return toAjax(kycFinanceService.deleteKycFinanceByFinanceIds(financeIds));
    }
}
